home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2002 #7 / K-CD-7-2002.ISO / Xara Webstyle 2.1 / WebStyleDwExt.cab / data1.cab / CfgUdShared / WSDwExCore.js
Encoding:
JavaScript  |  2002-01-09  |  19.7 KB  |  584 lines

  1. // API functions...
  2. function canInspectSelection()
  3. {
  4.     var docDOM = dreamweaver.getDocumentDOM("document");
  5.     if (!docDOM) { return false; }
  6.  
  7.     var selNode = docDOM.getSelectedNode();
  8.     if (!selNode) { return false; }
  9.  
  10.     var selAttr = selNode.getAttribute("Editor");
  11.     if (selAttr)
  12.     {
  13.         var bCanInspect = (selAttr == "Webstyle2");
  14.         if (bCanInspect)
  15.         {
  16.             selAttr = selNode.getAttribute("ModuleId");
  17.             bCanInspect = (selAttr && (selAttr != ""));
  18.         }
  19.  
  20.         return bCanInspect;
  21.     }
  22.  
  23.     // This should check for the translated version now...
  24.     var translatorClass = selNode.getAttribute("translatorClass");
  25.     if (!translatorClass || (translatorClass != "WSDwExTrans")) { return false; }
  26.  
  27.     var lockType = selNode.getAttribute("type");
  28.     if (!lockType || (lockType != "WSDwExTrans")) { return false; }
  29.  
  30.     return true;
  31. }
  32.  
  33. // Actually do something in the Property Inspector...
  34. function inspectSelection()
  35. {
  36.     var docDOM = dreamweaver.getDocumentDOM("document");
  37.     if (!docDOM) { return; }
  38.  
  39.     var selObj = docDOM.getSelectedNode();
  40.     if (!selObj) { return; }
  41.  
  42.     var selHTML = selObj.innerHTML;
  43.  
  44.     // Find the image name...
  45.     var imageSrc = selHTML.match(/img *src=\"([^\"]*)\"/i)[1];
  46.     var imgSrc = imageSrc.replace(/\\/g, "/");
  47.     var index = imgSrc.lastIndexOf("/");
  48.  
  49.     if (index != -1) { imgSrc = unescape(imgSrc.substr(index+1)); }
  50.     var piObject = findObject("WSPI File");
  51.     if (piObject  && imgSrc) { piObject.innerHTML = imgSrc.substr(0, 35); }
  52.  
  53.     // Find the project string within the moduleID...
  54.     var projectName = unescape(selHTML.match(/moduleid=\"\'*([^\"]*) \(Project\)\\[^\"]*\"/i)[1]);
  55.     piObject = findObject("WSPI Project");
  56.     if (piObject && projectName) { piObject.innerHTML = projectName.substr(0, 35); }
  57.  
  58.     // Set the alignment button/indicator as appropriate...
  59.     switch (dw.getDocumentDOM().getTextAlignment())
  60.     {
  61.         case 'left' :
  62.             wsSetLeftAlign();
  63.             break;
  64.  
  65.         case 'center' :
  66.             wsSetCenterAlign();
  67.             break;
  68.  
  69.         case 'right' :
  70.             wsSetRightAlign();
  71.             break;
  72.  
  73.         default :
  74.             wsSetNoAlign();
  75.             break;
  76.     }
  77.  
  78.     // Set the 'Link' input field...
  79.     piObject = findObject("WSPI Link Edit");
  80.     if (piObject) { piObject.value = unescape(getNodeAnchorAttribute(selObj, "href")); }
  81.  
  82.     // Set the 'Alt' input field...
  83.     piObject = findObject("WSPI Alt Edit");
  84.     if (piObject) { piObject.value = getNodeAlt(selObj); }
  85.  
  86.     // Set the 'Target' input field...
  87.     piObject = findObject("WSPI Target Edit");
  88.     if (piObject) { piObject.value = getNodeAnchorAttribute(selObj, "target"); }
  89.  
  90.     // Find the image in the dom...
  91.     if (!docDOM.images || (docDOM.images.length < 1)) { return; }
  92.     var selDomImage = null;
  93.  
  94.  
  95.     // We have to match the image name found earlier in the image list - this is not so easy as our NavBars have a <script><noscript> bit
  96.     // and the image list just constructs a default <img src="xxx"> tag around the image specified in our <noscript>...
  97.     var testString = "<img src=\"" + imageSrc + "\"";
  98.     for (var nCounter=0; nCounter < docDOM.images.length; nCounter++)
  99.     {
  100.         if (testString.toLowerCase() == docDOM.images[nCounter].outerHTML.substr(0,testString.length).toLowerCase())
  101.         {
  102.             selDomImage = docDOM.images[nCounter];
  103.             break;
  104.         }
  105.     }
  106.  
  107.     // Make some variables to hold the width and height data...
  108.     var docWidth = selObj.getAttribute("width");
  109.     var docHeight = selObj.getAttribute("height");
  110.     var bmpWidth = 0;
  111.     var bmpHeight = 0;
  112.  
  113.     // If we found the correct image in the DOM's image list, then proceed...
  114.     if (selDomImage)
  115.     {
  116.         // Get the image source as recorded in the DOM - this should be the absolute path used to locate the image...
  117.         var imageSource = selDomImage.src;
  118.         if (imageSource && !(docWidth && docHeight))
  119.         {
  120.             // Convert it to an absolute path and remove web-specific mark-up so that the bitmap importer can't get confused!
  121.             imageSource = dw.relativeToAbsoluteURL(getExportPath(), dw.getSiteRoot(), imageSource);
  122.             imageSource = unescape(imageSource);
  123.             imageSource = imageSource.replace(/file:\/\/\//gi, "");
  124.             imageSource = imageSource.replace(/|/gi, ":");
  125.             imageSource = imageSource.replace(/\//gi, "\\");
  126.  
  127.             // ***** TEMPORARY: The BmpImpr.dll doesn't work with PNGs!!! *****
  128.             if (imageSource.substr(imageSource.length-4, 4).toLowerCase() != ".png")
  129.             {
  130.                 // Call into our JS DLL and get Webstyle's bitmap importer to extract the image's dimensions...
  131.                 var result = WSDwExJs.GetImageDimensions(imageSource);
  132.                 bmpWidth = result[0];
  133.                 bmpHeight = result[1];
  134.             }
  135.         }
  136.     }
  137.  
  138.     // If we didn't know both values in the document, then we need to scale the other value by the one of the original file
  139.     if ((bmpWidth != 0) && (bmpHeight != 0))
  140.     {
  141.         if (!docWidth && docHeight) { docWidth = Math.floor((bmpWidth/bmpHeight) * docHeight); }
  142.         if (!docHeight && docWidth) { docHeight = Math.floor((bmpHeight/bmpWidth) * docWidth); }
  143.     }
  144.  
  145.     var imageWidth = "";
  146.     var imageHeight = "";
  147.     if (docWidth) { imageWidth = docWidth; } else if (bmpWidth != 0) { imageWidth = bmpWidth; }
  148.     if (docHeight) { imageHeight = docHeight; } else if (bmpHeight != 0) { imageHeight = bmpHeight; }
  149.  
  150.     // Set the 'Width' field...
  151.     piObject = findObject("WSPI Width");
  152.     if (piObject) { piObject.innerHTML = imageWidth; }
  153.  
  154.     // Set the 'Height' field...
  155.     piObject = findObject("WSPI Height");
  156.     if (piObject) { piObject.innerHTML = imageHeight; }
  157. }
  158.  
  159. // User has asked to insert a new object...
  160. function objectTag()
  161. {
  162.     webstyleNew(-1);
  163.     return("");
  164. }
  165.  
  166. // The menu items for Button, Logo, etc pass us an argument, which we should then pass on to the webstyleNew() function...
  167. function receiveArguments()
  168. {
  169.     if (arguments.length != 1) return;
  170.     var graphicType = arguments[0];
  171.     if (graphicType == 'U') { UpdateWebstyle(); return; }
  172.     webstyleNew(graphicType);
  173. }
  174.  
  175. // Turn the actual live HTML into something which can be displayed by both the DW editor and the browser. We save out the untranslated 'orig' to file...
  176. function translateMarkup(docNameStr, siteRootStr, inStr)
  177. {
  178. //    Sample HTML generated by Webstyle2.1...
  179. //<script webstyle2 src="C:\test\test.js">/* imgsrc="file:///C:\test\test.gif" moduleid="Default (Project)\test_off.xws"*/</script>
  180.     var wsPattern = /(\<script +webstyle2 +src *= *\"([^\"]*)\"\>)\/\* +imgsrc *= *\"([^\"]*)\" +moduleid *= *\"[^\"]*\"\*\/(\<\/script\>)/gi;
  181.     
  182.     var outStr = inStr.replace(wsPattern,
  183.         function (orig, scriptStart, scriptSrc, imgSrc, scriptEnd)
  184.         {
  185.             return "<MM:BeginLock translatorClass=\"WSDwExTrans\" type=\"WSDwExTrans\" orig=\"" + escape(orig) + "\">\n<script webstyle2 src=\"" + scriptSrc + "\"></script><noscript><br><img src=\"" + imgSrc + "\"><br></noscript>\n<MM:EndLock>";
  186.         });
  187.  
  188.     return outStr;
  189. }
  190.  
  191. // Function called by DW to establish if this translator can act on the current document...
  192. function getTranslatorInfo()
  193. {
  194.     var returnArray = new Array(9);
  195.  
  196.     returnArray[0] = "WSDwExTrans";            // The translatorClass
  197.     returnArray[1] = "Webstyle Translator";    // The title
  198.     returnArray[2] = "2";                                // The number of extensions
  199.     returnArray[3] = "html";                            // The second extension
  200.     returnArray[4] = "htm";                            // The third extension
  201.     returnArray[5] = "1";                                // The number of expressions
  202.     returnArray[6] = "<script webstyle2 ";        // Expression for PI and insert
  203.     returnArray[7] = "allFiles";                        // Default translation on for all files
  204.     returnArray[8] = "50";                            // priority order to apply translator
  205.  
  206.     return returnArray;
  207. }            
  208.  
  209. // API function - puts the 'Help' icon on our inspector and calls the correct help function...
  210. function displayHelp()
  211. {
  212.     showHelp();
  213. }
  214.  
  215.  
  216.  
  217.  
  218. // Webstyle-specific functions...
  219. // In the functions below, the webstyle js dll is executed and the return value ('result') is an array with the following components
  220. //    result[0]    Bool        Success
  221. //    result[1]    String    ModuleID
  222. //    result[2]    String    LiveHTML
  223. //    result[3]    String    PreviewHTML
  224.  
  225.  
  226. // Edit the current selection with Webstyle
  227. function webstyleEdit()
  228. {
  229.     var docDOM = dreamweaver.getDocumentDOM("document");
  230.     if (!docDOM) { return; }
  231.  
  232.     var selNode = docDOM.getSelectedNode();
  233.     if (!selNode) { return; }
  234.  
  235.     var modID = selNode.innerHTML.match(/moduleid *= *(\"[^\"]*\")/i);
  236.     if (!modID || !modID[1]) { return; }
  237.     modID = modID[1];
  238.  
  239.     // Find the state of the objects and properties floaters - if they are visible we will need to hide them...
  240.     var bShowObjectsFloater = dreamweaver.getFloaterVisibility("objects");
  241.     if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", false); }
  242.  
  243.     var bShowPropertiesFloater = dreamweaver.getFloaterVisibility("properties");
  244.     if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", false); }
  245.  
  246.     // Launch Webstyle to edit the image...
  247.     var result = WSDwExJs.Edit(modID, "", -1, getExportPath());
  248.     if (result[0] != true)
  249.     {
  250.         if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", true); }
  251.         if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", true); }
  252.         return;
  253.     }
  254.  
  255.     // Remove the single and double quotes...
  256.     modID = result[1].replace(/\'/g, "");
  257.     modID = modID.replace(/\"/g, "");
  258.  
  259.     // If we are replacing a non-translated object with another, then do the special case...
  260.     if ((selNode.outerHTML.search(/< *script/gi) == -1) && (result[2].search(/< *script/gi) == -1))
  261.     {
  262.         var imgSrc = result[2].match(/< *img +.*\bsrc *= *\"([^\"]*)\"/i)[1];
  263.         var selectedNode = selNode.outerHTML;
  264.         selectedNode = replaceModuleID(modID, selectedNode);
  265.         selectedNode = replaceImgSrc(imgSrc, selectedNode);
  266.         selectedNode = removeWidthAndHeight(selectedNode);
  267.         if (selectedNode && (selectedNode != "")) { selNode.outerHTML = selectedNode; }
  268.     }
  269.     else
  270.     {
  271.         // Get the currently selected node and update the html...
  272.         var offsets = docDOM.getSelection();
  273.         var docSrc = docDOM.documentElement.outerHTML;
  274.         var beforeSelStr = docSrc.substring(0, offsets[0]);
  275.         var afterSelStr = docSrc.substring(offsets[1]);
  276.  
  277.         // Assemble the new contents of the document.
  278.         docSrc = beforeSelStr + modifyWebstyleHTML(result[2], modID) + afterSelStr;
  279.         docDOM.documentElement.outerHTML = docSrc;
  280.         docDOM.setSelection(offsets[0], offsets[1]);
  281.     }
  282.  
  283.     // Force translator to execute...
  284.     forceTranslate();
  285.  
  286.     if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", true); }
  287.     if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", true); }
  288. }
  289.  
  290. // Replace the module ID parameter with a new one!
  291. function replaceModuleID(modID, strHTML)
  292. {
  293.     if (!modID || !strHTML) { return ""; }
  294.     return strHTML.replace(/(< *img +.*\bmoduleid *= *\")[^\"]*(\")/gi, function (orig, beforeModID, afterModID) { return beforeModID + modID + afterModID; } );
  295. }
  296.  
  297. // Replace the image source parameter...
  298. function replaceImgSrc(imgSrc, strHTML)
  299. {
  300.     if (!imgSrc || !strHTML) { return ""; }
  301.     return strHTML.replace(/(< *img +.*\bsrc *= *\")[^\"]*(\")/gi, function (orig, beforeImage, afterImage) { return beforeImage + imgSrc + afterImage; } );
  302. }
  303.  
  304. // Remove the width and height attributes...
  305. function removeWidthAndHeight(strHTML)
  306. {
  307.     if (!strHTML) { return ""; }
  308.  
  309.     // Remove the width and height...
  310.     strHTML = strHTML.replace(/(< *img +.*)\bwidth *= *\"[^\"]*\"/gi, function (orig, beforeWidth) { return beforeWidth; } );
  311.     strHTML = strHTML.replace(/(< *img +.*)\bheight *= *\"[^\"]*\"/gi, function (orig, beforeHeight) { return beforeHeight; } );
  312.     return strHTML;
  313. }
  314.  
  315. // Update Webstyle
  316. function UpdateWebstyle()
  317. {
  318.     // Launch Webstyle in Update mode...
  319.     var result = WSDwExJs.Update();
  320. }
  321.  
  322. // Create a new object with Webstyle
  323. function webstyleNew(graphicType)
  324. {
  325.     var docDOM = dreamweaver.getDocumentDOM("document");
  326.     if (!docDOM) { return; }
  327.  
  328.     // Find the state of the objects and properties floaters - if they are visible we will need to hide them...
  329.     var bShowObjectsFloater = dreamweaver.getFloaterVisibility("objects");
  330.     if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", false); }
  331.  
  332.     var bShowPropertiesFloater = dreamweaver.getFloaterVisibility("properties");
  333.     if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", false); }
  334.  
  335.     // Launch Webstyle to produce a new graphic with the current options...
  336.     var result = WSDwExJs.Edit(getExportPath(), getBackgroundColour(), graphicType, getExportPath());
  337.     if (result[0] != true)
  338.     {
  339.         if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", true); }
  340.         if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", true); }
  341.         return;
  342.     }
  343.  
  344.     // Remove the single and double quotes...
  345.     var modID = result[1].replace(/\'/g, "");
  346.     modID = modID.replace(/\"/g, "");
  347.  
  348.     // Insert the HTML Into the document...
  349.     docDOM.insertHTML(modifyWebstyleHTML(result[2], modID), false);
  350.  
  351.     // Force translator to execute...
  352.     forceTranslate();
  353.  
  354.     if (bShowObjectsFloater) { dreamweaver.setFloaterVisibility("objects", true); }
  355.     if (bShowPropertiesFloater) { dreamweaver.setFloaterVisibility("properties", true); }
  356. }
  357.  
  358. // Find the current document's export path - Webstyle will use this as the default directory to save images to...
  359. function getExportPath()
  360. {
  361.     var path = dreamweaver.getDocumentPath("document");
  362.  
  363.     var index = path.lastIndexOf('/');
  364.     if (index != -1) { path = path.substring(0, index); }
  365.  
  366.     return path;
  367. }
  368.  
  369. // Get the current document's background colour...
  370. function getBackgroundColour()
  371. {
  372.     var docDOM = dreamweaver.getDocumentDOM("document");
  373.     if (!docDOM) { return "NoColor"; }
  374.  
  375.     var bgCol = docDOM.body.bgcolor;
  376.     if (!bgCol) { bgCol = "NoColor"; }
  377.     return bgCol;
  378. }
  379.  
  380. // Get the dll to show the Webstyle help on the appropriate page...
  381. function showHelp()
  382. {
  383.     WSDwExJs.ShowHelp();
  384. }
  385.  
  386. // Get the dll to show the information for itself (file version etc)...
  387. function moduleInfo()
  388. {
  389.     WSDwExJs.ModuleInfo();
  390. }
  391.  
  392. // Function to force a translation - DW3 doesn't appear to run translators as often as DW4...
  393. function forceTranslate()
  394. {
  395.     dreamweaver.getDocumentDOM().documentElement.outerHTML = translateMarkup("", "", dreamweaver.getDocumentDOM().documentElement.outerHTML);
  396. }
  397.  
  398. // Change Webstyle produced HTML into something that DW can successfully display...
  399. function modifyWebstyleHTML(html, moduleid)
  400. {
  401.     //    Sample NavBar HTML generated by Webstyle2.1... We need to convert this into something Dreaweaver will display!
  402.     //    <script webstyle2 src="C:\WebStyle2.x\Export\testnav.js"></script><noscript><img src="../../../WebStyle2.x/Export/testnav.gif" editor="Webstyle2"></noscript>
  403.     var wsPattern = /(\<script +webstyle2 +src=\"[^\"]*\"\>)(\<\/script\>)\s*\<noscript\>\<img +src=\"([^\"]*)\" +editor=\"Webstyle2\"\>\<\/noscript\>/gi;
  404.     var dwString = html.replace(wsPattern, function (orig, scriptStart, scriptEnd, imgSrc) { return scriptStart + "\/\* imgsrc=\"" + escape(imgSrc) + "\" moduleid=\"" + escape(moduleid) + "\"\*\/" + scriptEnd; });
  405.     dwString = dwString.replace(/img +src=\"[^\"]*\" +editor=\"Webstyle2\"/i, function(orig) { return orig + " moduleid=\"" + moduleid + "\""; });
  406.     return dwString;
  407. }
  408.  
  409.  
  410. // Property Inspector Alignment Button/Indicator Functions...
  411. function wsPerformAlignment(desiredAlignment)
  412. {
  413.     var bVersionThree = false;
  414.     if (dw.appVersion)
  415.     {
  416.         var re = /^\d+/;
  417.         var appversion = dw.appVersion.match(re);
  418.         if (appversion && (appversion == 3)) { bVersionThree = true; }
  419.     }
  420.  
  421.     // If we're running on Dreamweaver3, we can set the alignment anytime, if we're in 4 then we can only set it when the
  422.     // focus is on the main preview editor - the 'document'
  423.     if (bVersionThree || (dw.getFocus(false) == 'document'))
  424.     {
  425.         // Update the alignment as requested...
  426.         dw.getDocumentDOM().setTextAlignment(desiredAlignment);
  427.  
  428.         // Update the property inspector to reflect this...
  429.         switch (desiredAlignment)
  430.         {
  431.             case 'left' :
  432.                 wsSetLeftAlign();
  433.                 break;
  434.  
  435.             case 'center' :
  436.                 wsSetCenterAlign();
  437.                 break;
  438.  
  439.             case 'right' :
  440.                 wsSetRightAlign();
  441.                 break;
  442.  
  443.             default :
  444.                 wsSetNoAlign();
  445.                 break;
  446.         }
  447.     }
  448.     else
  449.     {
  450.         alert("Object alignment cannot be adjusted at this time.\nPlease select the object in the document view.");
  451.     }
  452. }
  453.  
  454.  
  455. function wsSetNoAlign()
  456. {
  457.     setAlignObjectSelected("WSPI Align Left", false);
  458.     setAlignObjectSelected("WSPI Align Center", false);
  459.     setAlignObjectSelected("WSPI Align Right", false);
  460. }
  461.  
  462. function wsSetLeftAlign()
  463. {
  464.     setAlignObjectSelected("WSPI Align Left", true);
  465.     setAlignObjectSelected("WSPI Align Center", false);
  466.     setAlignObjectSelected("WSPI Align Right", false);
  467. }
  468.  
  469. function wsSetCenterAlign()
  470. {
  471.     setAlignObjectSelected("WSPI Align Left", false);
  472.     setAlignObjectSelected("WSPI Align Center", true);
  473.     setAlignObjectSelected("WSPI Align Right", false);
  474. }
  475.  
  476. function wsSetRightAlign()
  477. {
  478.     setAlignObjectSelected("WSPI Align Left", false);
  479.     setAlignObjectSelected("WSPI Align Center", false);
  480.     setAlignObjectSelected("WSPI Align Right", true);
  481. }
  482.  
  483. function isAlignObjectSelected(alignObject)
  484. {
  485.     var imgSrc = alignObject.innerHTML.match(/img *src=\"([^\"]*)\"/i)[1];
  486.     return (-1 != imgSrc.lastIndexOf("_sel.gif"));
  487. }
  488.  
  489. function setAlignObjectSelected(alignObjectId, bDesiredSelected)
  490. {
  491.     var alignObject = findObject(alignObjectId);
  492.     if (!alignObject) { return; }
  493.  
  494.     var bSelected = isAlignObjectSelected(alignObject);
  495.     if (bDesiredSelected && !bSelected) { alignObject.innerHTML = alignObject.innerHTML.replace(/\.gif\"/i, "_sel.gif\""); }
  496.     if (!bDesiredSelected && bSelected) { alignObject.innerHTML = alignObject.innerHTML.replace(/_sel\.gif\"/i, ".gif\""); }
  497. }
  498.  
  499. // Property Inspector Link/Target Edit Field function...
  500. function webstyleAnchorAttributeEdit(anchorAttribute, piObject, bEscape)
  501. {
  502.     var docDOM = dw.getDocumentDOM("document");
  503.     if (!docDOM || !piObject) { return; }
  504.  
  505.     var selNode = docDOM.getSelectedNode();
  506.     if (!selNode) { return; }
  507.  
  508.     var newValue = findObject(piObject).value;
  509.     if (bEscape) { newValue = escape(newValue); }
  510.     if (!replaceNodeAnchorAttribute(selNode, anchorAttribute, newValue) && (newValue != ""))
  511.     {
  512.         // Then this node doesn't have a parent which is an anchor tag, so wrap it in one!...
  513.         docDOM.wrapTag("<a "+anchorAttribute+"=\"" + newValue + "\">");
  514.     }
  515. }
  516.  
  517. // Property Inspector Alt Edit Field functions...
  518. function webstyleAltEdit()
  519. {
  520.     var docDOM = dw.getDocumentDOM("document");
  521.     if (!docDOM) { return; }
  522.  
  523.     var selNode = docDOM.getSelectedNode();
  524.     if (!selNode) { return; }
  525.  
  526.     var piObject = findObject("WSPI Alt Edit");
  527.     if (!piObject) { return; }
  528.  
  529.     var newValue = piObject.value;
  530.     if (newValue != getNodeAlt(selNode)) { selNode.setAttribute("alt", newValue); }
  531. }
  532.  
  533. function getNodeAlt(currentNode)
  534. {
  535.     if (!currentNode) { return ""; }
  536.  
  537.     var currentAlt = currentNode.getAttribute("alt");
  538.     if (!currentAlt) { currentAlt = ""; }
  539.     return currentAlt;
  540. }
  541.  
  542. // Generic functions to recursively search up the tree from the specified node looking for an anchor tag which is the parent of the current node
  543. // Once found, the specified attribute is modified to the new value.
  544. function replaceNodeAnchorAttribute(currentNode, anchorAttribute, newValue)
  545. {
  546.     if (!currentNode) { return false; }
  547.  
  548.     var currentTag = currentNode.tagName;
  549.     if (!currentTag) { return false; }
  550.  
  551.     if (currentTag == "A")
  552.     {
  553.         if (currentNode.getAttribute(anchorAttribute) != newValue) { currentNode.setAttribute(anchorAttribute, newValue); }
  554.         return true;
  555.     }
  556.     else
  557.     {
  558.         return replaceNodeAnchorAttribute(currentNode.parentNode, anchorAttribute, newValue);
  559.     }
  560. }
  561.  
  562. function getNodeAnchorAttribute(currentNode, anchorAttribute)
  563. {
  564.     if (!currentNode) { return ""; }
  565.  
  566.     var currentTag = currentNode.tagName;
  567.     if (!currentTag) { return ""; }
  568.  
  569.     if (currentTag == "A")
  570.     {
  571.         var attributeValue = currentNode.getAttribute(anchorAttribute);
  572.         if (!attributeValue || (attributeValue == "undefined")) { attributeValue = ""; }
  573.         return attributeValue;
  574.     }
  575.     else
  576.     {
  577.         return getNodeAnchorAttribute(currentNode.parentNode, anchorAttribute);
  578.     }
  579. }
  580.  
  581. function removeXolDummyWSMenu()
  582. {
  583.     WSDwExJs.RemoveDreamweaverXolDummyWSMenu(dreamweaver.getConfigurationPath());
  584. }